package com.IDWORLD;

import android.app.Activity;
import android.content.Context;
import android.util.Log;

public class LAPI {
   static final String TAG = "LAPI";

   private static final boolean D = false;

   public static final int VID = 1155;

   public static final int PID = 22288;

   private static HostUsb m_usbHost = null;

   private static int m_hUSB = 0;

   public static final int MSG_OPEN_DEVICE = 16;

   public static final int MSG_CLOSE_DEVICE = 17;

   public static final int MSG_BULK_TRANS_IN = 18;

   public static final int MSG_BULK_TRANS_OUT = 19;

   public static final int WIDTH = 256;

   public static final int HEIGHT = 360;

   public static final int IMAGE_SIZE = 92160;

   public static final int FPINFO_STD_MAX_SIZE = 1024;

   public static final int DEF_QUALITY_SCORE = 30;

   public static final int DEF_MATCH_SCORE = 45;

   public static final int TRUE = 1;

   public static final int FALSE = 0;

   private static Activity m_content = null;

   static {
      try {
         System.loadLibrary("biofp_e_lapi");
      } catch (UnsatisfiedLinkError unsatisfiedLinkError) {}
   }

   public LAPI(Activity a) {
      m_content = a;
   }

   private static void writeLog(String fileName, String content) {
      Log.e("LAPI", content);
   }

   public int getrwusbdevices() {
      m_usbHost = new HostUsb();
      if (!m_usbHost.AuthorizeDevice((Context)m_content, 1155, 22288)) {
         m_usbHost = null;
         return 0;
      }
      if (!m_usbHost.WaitForInterfaces()) {
         m_usbHost = null;
         return 0;
      }
      m_hUSB = m_usbHost.OpenDeviceInterfaces();
      if (m_hUSB <= 0) {
         m_usbHost = null;
         return 0;
      }
      return m_hUSB;
   }

   private static int CallBack(int message, int notify, int param, Object data) {
      switch (message) {
         case 16:
            m_usbHost = new HostUsb();
            if (!m_usbHost.AuthorizeDevice((Context)m_content, 1155, 22288)) {
               m_usbHost = null;
               return 0;
            }
            if (!m_usbHost.WaitForInterfaces()) {
               m_usbHost = null;
               return 0;
            }
            m_hUSB = m_usbHost.OpenDeviceInterfaces();
            if (m_hUSB <= 0) {
               m_usbHost = null;
               return 0;
            }
            return m_hUSB;
         case 17:
            if (m_usbHost != null) {
               m_usbHost.CloseDeviceInterface();
               m_hUSB = -1;
               m_usbHost = null;
            }
            return 1;
         case 18:
            m_usbHost.USBBulkReceive((byte[])data, notify, param);
            return 1;
         case 19:
            m_usbHost.USBBulkSend((byte[])data, notify, param);
            return 1;
      }
      return 0;
   }

   public native String GetVersion();

   public native int OpenDevice();

   public native int CloseDevice(int paramInt);

   public native int GetImage(int paramInt, byte[] paramArrayOfbyte);

   public native int Calibration(int paramInt);

   public native int IsPressFinger(int paramInt, byte[] paramArrayOfbyte);

   public native int CreateTemplate(int paramInt, byte[] paramArrayOfbyte1, byte[] paramArrayOfbyte2);

   public native int GetImageQuality(int paramInt, byte[] paramArrayOfbyte);

   public native int CompareTemplates(int paramInt, byte[] paramArrayOfbyte1, byte[] paramArrayOfbyte2);
}
